/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package org.aroundme.unittests;

import junit.framework.TestCase;

import org.aroundme.model.Search;

public class SearchTest extends TestCase {
	private Search search;	
	
	protected void setUp() throws Exception {
		super.setUp();
		search = new Search("all");
	}

	protected void tearDown() throws Exception {
		super.tearDown();
		search = null;
	}

	public void testAddRemoveKeyword() {
		String key1 = "restaurant";
		String key2 = "hello";
		
		search.addKeywordAND(key1);
		search.addKeywordAND(key2);
		
		boolean foundKey1 = false;
		boolean foundKey2 = false;
		for (String s : search.getKeywordsAND()) {
			if(s.equals(key1)){
				foundKey1 = true;
			}else if(s.equals(key2)){
				foundKey2 = true;
			}
		}
		
		assertTrue(foundKey1);
		assertTrue(foundKey2);
		
		//remove key1
		search.removeKeywordAND(key1);
		
		foundKey1 = false;
		foundKey2 = false;
		for (String s : search.getKeywordsAND()) {
			if(s.equals(key1)){
				foundKey1 = true;
			}else if(s.equals(key2)){
				foundKey2 = true;
			}
		}
		
		assertFalse(foundKey1);
		assertTrue(foundKey2);
		
	}


}
